package com.neuedu.ylbx.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neuedu.ylbx.pojo.PatientRegistration;
import com.neuedu.ylbx.pojo.ginseng;
import com.neuedu.ylbx.service.SumExpenseService;
import com.neuedu.ylbx.utils.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/reimbursement")
@Api(tags = "参保人员费用汇总")
@CrossOrigin
public class SumExpenseController {
    @Autowired
    private SumExpenseService sumExpenseService;

    @ApiOperation("获取参保人员费用汇总")
    @PostMapping("/participant-expense/{participantId}")
    public ResultVo getSumExpense(Integer id)throws Exception{
        QueryWrapper<ginseng> qw = new QueryWrapper<>();
        //查询患者id
        if (id != null) {
            qw.eq("id", id);
        }
        //执行查询
        List<ginseng> ginsengList = sumExpenseService.list(qw);
        Double sum = ginsengList.get(0).getDrugPrice()+ginsengList.get(0).getMedicalPrice()+ginsengList.get(0).getMedicalServicePrice();
        return ResultVo.ok(sum);
    }
}
